<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://users">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	
	
	<xsl:include href="../main.xsl" />
	<xsl:include href="menu.xsl" />
	<xsl:include href="../common/form.xsl" />

	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/user-profile.css" type="text/css" media="all" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />
			
			<!-- Header -->
			<div id="header">
				<xsl:call-template name="logo" />
				
				<!-- Menu -->
				<xsl:call-template name="menu" />
			</div>
			<!-- /Header -->
			
			<!-- Blocks -->
			<div id="blocks">
				<div id="blocks_inner">
					<xsl:call-template name="default-blocks-top" />
				</div>
			</div>
			<!-- // Blocks -->
			
			<!-- Content -->
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			<!-- // Content -->
			
			<!-- Address -->
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	
	<xsl:template match="response">
		<h1>&labelEditProfile;</h1>
		
		<div id="small_menu">
			<a href="{$baseURI}/users/edit_profile">&labelEditPersonal;</a>
			<a href="{$baseURI}/users/avatars_manager" class="selected">&labelAvatars;</a>
			<a href="{$baseURI}/users/site_settings">&labelEditSite;</a>
			<a href="{$baseURI}/users/change_password">&labelChangePass;</a>
		</div>
		<xsl:apply-templates select="error" />
		<form action="{$baseURI}/users/avatars_manager" method="post" enctype="multipart/form-data">
			<div id="avatars_manager">
				<xsl:for-each select="object[@type='avatar']">
					<div class="avatar_item">
						<xsl:if test="@active = '1'">
							<xsl:attribute name="class">avatar_item selected</xsl:attribute>
						</xsl:if>
						<img align="left" alt="">
							<xsl:attribute name="src">
								<xsl:value-of select="concat ($baseURI, '/thumb_100_100', property[@name='image']/value)" />
							</xsl:attribute>
						</img>
						<input type="radio" name="selected" id="set_active_{@id}" value="{@id}">
							<xsl:if test="@active = '1'">
								<xsl:attribute name="checked">checked</xsl:attribute>
							</xsl:if>
						</input>
						<label for="set_active_{@id}">&labelAvatarActive;</label>
						<br />
						<input type="checkbox" id="delete_{@id}" name="delete[]" value="{@id}" />
						<label for="delete_{@id}">&labelDeleteAvatar;</label>
					</div>
				</xsl:for-each>
				<p>
					<xsl:if test="@used &lt; @allowed">
						<xsl:text>&labelNewAvatar;: </xsl:text>
						<input type="file" name="data[new][image]" /><xsl:text> </xsl:text>
						<input type="checkbox" name="setactive" value="1" id="setactive" /> <label for="setactive">&labelSetAvatarActive;</label>
						<xsl:text> </xsl:text><input type="submit" name="upload" value="&labelUploadAvatar;" />
						<br /><br />
						<xsl:text>&labelYouUpload1; </xsl:text>
						<xsl:value-of select="@used" />
						<xsl:text> &labelYouUpload2; </xsl:text>
						<xsl:value-of select="@allowed" />
						<xsl:text> &labelYouUpload3;.</xsl:text>
					</xsl:if>
					<xsl:if test="@used &gt;= @allowed">
						<strong>&labelAvatarErrorMax;.</strong>
					</xsl:if>
				</p>
			</div>
			<p><input type="submit" name="save" value="&labelSaveButton;" /></p>
		</form>
	</xsl:template>
	
</xsl:stylesheet>